﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using nplJobsCommon.Common;

namespace nplJobsDAL.Select
{
    public class SelectMaritalStatus : DataAccessBase
    {
        public SelectMaritalStatus()
        {
            StoredProcedureName = StoredProcedure.Name.spMaritalStatus.ToString();
        }

        #region GetMaritalStatus
        public List<MaritalStatus> GetMaritalStatus()
        {
            DataBaseHelper dbHelper;
            DataSet dsMaritalStatus;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsMaritalStatus = dbHelper.Run(base.ConnectionString);
                return GetList(dsMaritalStatus);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<MaritalStatus> GetList(DataSet dsMaritalStatus)
        {
            List<MaritalStatus> maritalStatus;
            try
            {
                maritalStatus = (from n in dsMaritalStatus.Tables[0].AsEnumerable()
                                 select new MaritalStatus
                                   {
                                       ID = n.Field<int>("ID"),
                                       Status= n.Field<string>("Status")
                                   }).ToList();

                return maritalStatus;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}
